package com.xwy.usercenter.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xwy.usercenter.common.BaseResponse;
import com.xwy.usercenter.common.ErrorCode;
import com.xwy.usercenter.exception.BusinessException;
import com.xwy.usercenter.model.User;
import com.xwy.usercenter.model.vo.UserVO;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.security.NoSuchAlgorithmException;
import java.util.List;

import static com.xwy.usercenter.utils.SystemConstants.ADMIN_ROLE;
import static com.xwy.usercenter.utils.SystemConstants.USER_LOGIN_STATUS;

/**
 * 用户服务
 *
 * @author xwy
 */
@Service
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @param userAccount 用户账户
     * @param userPassword 用户密码
     * @param checkPassword 校验密码
     * @return 新用户id
     */
    Long userRegister(String userAccount, String userPassword, String checkPassword, String plantCode);

    /**
     * 用户登录
     * @param userAccount 用户账户
     * @param userPassword 用户密码
     * @return 返回脱敏后的用户信息
     */
    User login(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * 用户退出登录
     * @param request
     * @return
     */
    BaseResponse<Integer> logout(HttpServletRequest request);

    /**
     * 根据用户标签查询用户
     * @param tagsLists
     * @return
     */
    List<User> searchUsersBytags(List<String> tagsLists);

    List<User> searchUsersBytagsBySql(List<String> tagsLists);

    /**
     * 返回脱敏的用户信息
     * @param user
     * @return
     */
    User safetyUser(User user);

    /**
     * 更新用户信息
     * @param user
     * @param loginUser
     */
    Integer updateUser(User user, User loginUser);

    Page<User> recommendUser(Long pageSize, Long pageNum, HttpServletRequest request);

    /**
     * 返回当前已登录的用户，若未登录则报登录异常
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 是否为管理员
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 是否为管理员（方法重载）
     * @param loginUser
     * @return
     */
    boolean isAdmin(User loginUser);

    /**
     * 匹配用户
     * @param num
     * @param user
     * @return
     */
    List<User> matchUsers(long num, User user);
}
